package com.mycat.tencent.entity.request;

import com.alipay.api.internal.util.StringUtils;
import com.mycat.exception.PaymentException;

import java.util.HashMap;
import java.util.Map;

/**
 * App端调起支付参数
 * @author roger.
 * @email luojie@yzworld.cn
 * @date 2016/9/7
 */
public class WxAppPaymentParams {
    // 应用ID
    private String appid;
    // 商户号
    private String partnerid;
    // 预支付交易会话ID
    private String prepayid;
    // 扩展字段
//    private String package="Sign=WXPay";
    // 随机字符串
    private String noncestr;
    // 时间戳
    private String timestamp;
    // 签名
    private String sign;
    public Map<String,Object> toMap() throws Exception{
        Map<String,Object> map = new HashMap<>();
        if(StringUtils.isEmpty(this.getAppid())){
            throw new PaymentException("应用ID不能为空");
        }
        map.put("appid",this.getAppid());
        if(StringUtils.isEmpty(this.getPartnerid())){
            throw new PaymentException("商户号不能为空");
        }
        map.put("partnerid",this.getPartnerid());
        if(StringUtils.isEmpty(this.getPrepayid())){
            throw new PaymentException("预支付交易会话ID不能为空");
        }
        map.put("prepayid",this.getPrepayid());
        return map;
    }
    public String getAppid() {
        return appid;
    }

    public void setAppid(String appid) {
        this.appid = appid;
    }

    public String getPartnerid() {
        return partnerid;
    }

    public void setPartnerid(String partnerid) {
        this.partnerid = partnerid;
    }

    public String getPrepayid() {
        return prepayid;
    }

    public void setPrepayid(String prepayid) {
        this.prepayid = prepayid;
    }

    public String getNoncestr() {
        return noncestr;
    }

    public void setNoncestr(String noncestr) {
        this.noncestr = noncestr;
    }

    public String getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(String timestamp) {
        this.timestamp = timestamp;
    }

    public String getSign() {
        return sign;
    }

    public void setSign(String sign) {
        this.sign = sign;
    }
}
